<template>
  <van-nav-bar title="运动" left-text="返回" left-arrow @click-left="onClickLeft" />
  <div class="ab">
    <div class="v">
      <div class="l">
        <h1>{{ time }}</h1>
        <p>运动时长</p>
      </div>
      <div class="y">
        <h1>{{ hot }}</h1>
        <p>消耗热量(kcal)</p>
      </div>
    </div>
    <div class="ae">
      <p>还没有您的运动记录</p>
      <p>通过智能设备上传您的运动数据，看看健康顾问怎么说</p>
    </div>
  </div>
  <div class="af">
    <p><span>近7天记录</span>&emsp;&emsp;&emsp; <span @click="amove()">查看更多记录</span></p>
    <div ref="main" style="width: 100%; height: 400px"></div>
    <div class="ae">
      如果你从早到晚都佩戴着手环/智能手表，可能会让你将生活步数与运动步数混淆。生活中的步行，并不能起到运动效果。要起到锻炼作用，还需要兼顾运动强度。每天应有30分钟中等强度的运动。若你的运动方式是行走，那么要达到每分钟110~130步的步频，才算做进行了中等强度锻炼。
    </div>
  </div>
  <div class="ar">
    <h4>智能设备</h4>
    <dl>
      <dt>
        <img src="../../img/icon_watch.png" />
      </dt>
      <dd>
        <p>健利达动感单车DeepsMove&emsp;S8&emsp;Pro</p>
        <p>10</p>
      </dd>
    </dl>
  </div>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import * as echarts from 'echarts'
const router = useRouter()
const main = ref<HTMLDivElement>()
const time = ref('0')
const hot = ref('0')
const newdata = ref([0, 7, 6, 3, 5, 5, 7, 6, 8, 9, 5])
onMounted(() => {
  const myChart = echarts.init(main.value)
  const option = {
    xAxis: {
      type: 'category',
      data: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
    },
    yAxis: {
      type: 'value',
      splitLine: { show: false },
      axisLabel: {
        formatter: ['18:00', '22:00', '02:00', '06:00', '10:00', '14:00']
      },
      axisLine: { show: false },
      axisTick: { show: false },
      grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
      }
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'cross'
      },
      formatter: '{a} <br/>{b}: {c}小时'
    },
    series: [
      {
        data: newdata.value,
        type: 'line',
        smooth: true
      }
    ]
  }
  myChart.setOption(option)
})
const onClickLeft = () => {
  router.go(-1)
}
const amove = () => {
  router.push('/amove')
}
</script>
<style>
template {
  background: whitesmoke !important;
}
.ab {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  width: 100%;
  height: 200px;
  padding: 10px;
  text-align: center;
  background: white;
  margin-top: 10px;
  .ae {
    width: 100%;
    height: 90px;
    background: whitesmoke !important;
    margin-top: 20px;
    text-align: left;
    line-height: 40px;
  }
}
.v {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 70px;
  line-height: 40px;
  .l {
    width: 50%;
    height: 100%;
    float: left;
    h1 {
      font-size: 24px;
    }
  }
  .y {
    width: 50%;
    height: 100%;
    float: right;
    h1 {
      font-size: 24px;
    }
  }
}
.af {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 500px;
  padding: 10px;
  text-align: center;
  background: white;
  margin-top: 10px;
}
.ar {
  width: 100%;
  height: 200px;
  padding: 10px;
  text-align: center;
  background: white;
  margin-top: 10px;
  h4 {
    float: left;
  }
  dl {
    margin-top: 10px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 80px;
    dt {
      width: 30%;
      height: 100%;
      margin-right: 10px;
      img {
        width: 100px;
        height: 100px;
      }
    }
    dd {
      width: 70%;
      height: 100%;
      float: left;
      p {
        font-size: 14px;
        color: #333333;
      }
    }
  }
}
.ae {
  width: 100%;
  height: 170px;
  background: whitesmoke !important;
  margin-top: 10px;
  text-align: justify;
  line-height: 26px;
}
</style>
